package org.ucas.kgraph.dto;

import org.springframework.http.HttpStatus;
import org.ucas.kgraph.dto.TermGraphDto.Node;
import org.ucas.kgraph.entity.RelationType;
import org.ucas.kgraph.entity.Relation;
import org.ucas.kgraph.entity.Term;
import org.ucas.kgraph.entity.TermGraph;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 返回前端需要的格式以构建局部图结构
 *
 * @author suemi
 */
//{"meta":{"name":"demo","author":"zhangyipin","version":"0.2"},"format":"node_array","data":[{"id":"0","topic":"322 ","expanded":true,"isroot":true,"root":true}]}

public class GraphDto extends ResponseDto {
	 

	public Met meta;  
	public String format;
	public List<Node> data;
	
	public static class Met {  
		public String name;  
		public String author;  
		public String version;
		
		
		
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getAuthor() {
			return author;
		}
		public void setAuthor(String author) {
			this.author = author;
		}
		public String getVersion() {
			return version;
		}
		public void setVersion(String version) {
			this.version = version;
		}
	} 
	public static class Node {  
		public String id;
	    public String parentid;
	    public String topic;
	    public Long document;
	    public boolean isroot;
	    public boolean expanded;
	    public boolean root;
	    public List<Link> link;
	    //public String link;
	    public Float cost;
	    public String tags;
	    public String direction;
	    
		public String getId() {
			return id;
		}
		public static class Link{
		    	public String to;
		    	public float refer1x;
		    	public float refer1y;
		    	public float refer2x;
		    	public float refer2y;
		    	public String linkmsg;
		    	
		    	
		    	public Relation writeto(Long fromid,Long toid,Relation relation){
		    		relation.setLeftEnd(toid);
		    		relation.setRightEnd(fromid);
					relation.setName(this.linkmsg+";"+this.refer1x+";"+this.refer1y+";"+this.refer2x+";"+this.refer2y);
					relation.setCategory(RelationType.Link);
				    return relation;
				}
		    	
				public String getTo() {
					return to;
				}
				public void setTo(String to) {
					this.to = to;
				}
				public float getRefer1x() {
					return refer1x;
				}
				public void setRefer1x(float refer1x) {
					this.refer1x = refer1x;
				}
				public float getRefer1y() {
					return refer1y;
				}
				public void setRefer1y(float refer1y) {
					this.refer1y = refer1y;
				}
				public float getRefer2x() {
					return refer2x;
				}
				public void setRefer2x(float refer2x) {
					this.refer2x = refer2x;
				}
				public float getRefer2y() {
					return refer2y;
				}
				public void setRefer2y(float refer2y) {
					this.refer2y = refer2y;
				}
				public String getLinkmsg() {
					return linkmsg;
				}
				public void setLinkmsg(String linkmsg) {
					this.linkmsg = linkmsg;
				}
		    	
		}
		public Term writeto(Term term){
			term.setDefinition(this.topic);
			term.setTags(this.tags);
			if(this.tags!=null){
				term.setTagList(Arrays.asList(this.tags.split(";")));
			}
			term.setDocumentId(this.document);
			term.setDirection(this.direction);
			term.setCost(this.cost);
		    return term;
		}
		
		public Long getDocument() {
			return document;
		}

		public void setDocument(Long document) {
			this.document = document;
		}

		public void setId(String id) {
			this.id = id;
		}
		public String getParentid() {
			return parentid;
		}
		public void setParentid(String parentid) {
			this.parentid = parentid;
		}
		public String getTopic() {
			return topic;
		}
		public void setTopic(String topic) {
			this.topic = topic;
		}
		public boolean isIsroot() {
			return isroot;
		}
		public void setIsroot(boolean isroot) {
			this.isroot = isroot;
		}
		public boolean isExpanded() {
			return expanded;
		}
		public void setExpanded(boolean expanded) {
			this.expanded = expanded;
		}
		public boolean isRoot() {
			return root;
		}
		public void setRoot(boolean root) {
			this.root = root;
		}
		
		public List<Link> getLink() {
			return link;
		}

		public void setLink(List<Link> links) {
			this.link = links;
		}

		public String getTags() {
			return tags;
		}
		public void setTags(String tags) {
			this.tags = tags;
		}
		public String getDirection() {
			return direction;
		}
		public void setDirection(String direction) {
			this.direction = direction;
		}

		public Float getCost() {
			return cost;
		}

		public void setCost(Float cost) {
			this.cost = cost;
		} 
		
		
	}
	public Met getMeta() {
		return meta;
	}
	public void setMeta(Met meta) {
		this.meta = meta;
	}
	public String getFormat() {
		return format;
	}
	public void setFormat(String format) {
		this.format = format;
	}
	public List<Node> getData() {
		return data;
	}
	public void setData(List<Node> data) {
		this.data = data;
	} 
	
	
	
	
	
	
}
